<!DOCTYPE html>
<html lang="zh-CN"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>商品详情页</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{layui/css/layui.css}"  media="all">
    <script type="text/javascript" charset="utf-8" th:src="@{/ueditor/ueditor.config.js}"></script>
    <script type="text/javascript" charset="utf-8" th:src="@{/ueditor/ueditor.all.min.js}"> </script>

    <script type="text/javascript" charset="utf-8" th:src="@{/ueditor/lang/zh-cn/zh-cn.js}"></script>
    <style type="text/css">
        #editor{
            margin-left: 110px;
        }
    </style>
</head>
<body>
<form id="addDetils" name="addDetils" th:action="@{/addProductDetils}" method="get">
    <input type="hidden" id="productId" name="productId" autocomplete="off" value="4565423" class="layui-input">
    <div class="layui-form-item">
        <label class="layui-form-label">商品编号</label>
        <div class="layui-input-block">
            <input type="text" id="productNo" name="productNo" autocomplete="off" value="dfgsdfg" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label" >商品名称</label>
        <div class="layui-input-block">
            <input type="text" id="productName" name="productName" autocomplete="off" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">规格编号</label>
        <div class="layui-input-block">
            <input type="text" id="g_id" name="g_id" autocomplete="off" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">商品详情</label>
            <div id="editor" type="text/plain" style="width:620px;height:500px;"></div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="demo1" onclick="getSave()">保存</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script th:src="@{layui/layui.js}" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8" th:src="@{/ueditor/ueditor.all.js}"> </script>
<script type="text/javascript" charset="utf-8" th:src="@{/layui/jquery.min.js}"> </script>

<script>
    var ue = UE.getEditor('editor');
    ue.ready(function () {
        ue.setContent("这里编辑你的商品详情！");
    })

    // var ue = UE.getEditor('container');
    // UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
    // UE.Editor.prototype.getActionUrl = function(action) {
    //     if (action == 'uploadImg') {
    //         return 'http://localhost:8092/uploadImg/'; //在这里返回我们实际的上传图片地址
    //     } else {
    //         return this._bkGetActionUrl.call(this, action);
    //     }
    // }

    // var content= ue.getContent();
    // alert(content);
   function getSave() {
        var productId=$('#productId').val();
        alert(productId);
       alert( UE.getEditor('editor').getContent());
       var content= UE.getEditor('editor').getContent();

    $.ajax({
        url:"/uploadImg?content="+content

    })
   }

</script>

</body>
</html>